using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Markup;

namespace QueryBuilder.Controls.Configuration
{
    [ContentProperty("Items")]
    public class ComparisonTemplateConfiguration
    {
        private Collection<ComparisonTemplateMapping> items = new Collection<ComparisonTemplateMapping>();


        public Collection<ComparisonTemplateMapping> Items
        {
            get { return this.items; }
        }

        public IEnumerable<TemplateSection> GetComparisonTemplate(string comparisonName)
        {
            var result = (from element in items
                   where string.Equals(element.ComparisonName, comparisonName, StringComparison.InvariantCultureIgnoreCase)
                   select element.ComparisonTemplate.Items).FirstOrDefault();
            return result;
        }
    }
}